package com.seeingtv.controller;

import com.seeingtv.controller.base.BaseController;
import com.seeingtv.model.Cp;
import com.seeingtv.service.CpService;
import com.seeingtv.vo.page.TableDataInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author hubert
 * @date 2018/8/3
 * @description CpController
 */
@Controller
@RequestMapping("/cp")
public class CpController extends BaseController{
	/*前缀*/
	private String prefix = "cp";

	@Autowired
	private CpService cpService;

	/**
	 *  ModelAndView 指定路径
	 *  使用前端js框架加载数据，因此先跳转html页面，再获取数据
	 *  RequestMapping 路径可以为空，访问时为{project}/cp
	 *  //@GetMapping()相当于指定方法为get的//@RequestMapping()
	 */
	@GetMapping()
	public String cp(){
		//页面跳转
		return prefix + "/list";
	}

	@RequiresPermissions("view")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Cp cp) {
		//分页
		startPage();
		List<Cp> list = cpService.selectRoleList(cp);
		return getDataTable(list);
	}
}
